home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / comm / amiex / KLR_ChatSRC.lha / Chat-O-Meter_Log.C < prev    next >
C/C++ Source or Header  |  1995-06-29  |  1KB  |  55 lines

  1. #define COM_LOG
  2. #include "Chat-O-Meter.H"
  3.  
  4. extern struct Library    *DOSBase;
  5. extern UBYTE  ErrStr[];
  6.  
  7. VOID LogChat( ULONG chat_Start , ULONG chat_Time )
  8. {
  9.     UBYTE    temp[ 100 ];
  10.  
  11.     BPTR    fh;
  12.  
  13.     struct CHAT_LOG *cl_ptr;
  14.  
  15.     /* Allocate memory for log entry */
  16.     if ( cl_ptr = AllocVec( sizeof( struct CHAT_LOG ) , MEMF_PUBLIC|MEMF_CLEAR ) )
  17.     {
  18.         /* Fill entry with info */
  19.         cl_ptr->cl_Start = chat_Start;
  20.         cl_ptr->cl_End   = chat_Start + chat_Time;
  21.  
  22.         /* Fill in slotnumber of user */
  23.         getuserstring( temp , DT_SLOTNUMBER );
  24.         cl_ptr->cl_Slotnumber = atol( temp );
  25.  
  26.         /* Open the logfile */
  27.         if ( fh = Open( "PROGDIR:Chat-O-Meter.Log" , MODE_READWRITE ) )
  28.         {
  29.             /* Go to the end */
  30.             Seek( fh , 0 , OFFSET_END );
  31.             
  32.             /* Save the new entry */
  33.             Write( fh , cl_ptr , sizeof( struct CHAT_LOG ) );
  34.             
  35.             /* And close it again */
  36.             Close( fh );
  37.         }
  38.         else
  39.         {
  40.             sprintf( temp , ErrStr , "log this chat." );
  41.             sm( temp , 1 );
  42.             FreeVec( cl_ptr );
  43.             enddoor( FALSE );
  44.         }
  45.         /* Free memory again */
  46.         FreeVec( cl_ptr );
  47.     }
  48.     else
  49.     {
  50.         sprintf( temp , ErrStr , "allocate enough memory." );
  51.         sm( temp , 1 );
  52.         enddoor( FALSE );
  53.     }
  54. }
  55.